package com.cn.hnust.controller.hcontroller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cn.hnust.pojo.Customer;
import com.cn.hnust.service.ICustomerService;

@Controller
@RequestMapping(value = "/hCustomer")
public class HCustomerController {

    @Autowired
    private ICustomerService CustomerService;

    @RequestMapping("/toCustomer")
    private String home(Model model, Customer Customer){
        List<Customer> list=CustomerService.selectAllCustomer(Customer);
        System.out.println("list:"+list.size());
        model.addAttribute("customerlist", list);
        return "customer";
    }
    
    @RequestMapping("/deleteCustomer")
    private String deleteCustomer(Model model, Customer Customer,Integer id){
    	CustomerService.deleteByPrimaryKey(id);
    	 List<Customer> list=CustomerService.selectAllCustomer(Customer);
         System.out.println("list:"+list.size());
         model.addAttribute("customerlist", list);
         return "customer";
    }

}
